﻿/*----------------------------------------------------------------
// Copyright (C) 2012 Q.FunnyFace
// 版权所有。 
//
// 文件名：CompanyConfiguration.cs
// 文件功能描述：企业信息数据库映射
//
// 
// 创建标识：2012-10-29 zhangqiang
//
// 修改标识：
// 修改描述：
//
//
//----------------------------------------------------------------*/
using DomainModel;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;
using System.Linq;
using System.Text;

namespace Infrastructure.Mapper
{

    /// <summary>
    /// 企业信息数据库映射
    /// </summary>
    public class CompanyConfiguration : EntityTypeConfiguration<CompanyInfo>
    {

        /// <summary>
        /// 映射数据库表/字段
        /// </summary>
        public CompanyConfiguration()
        {
            ToTable("CTB_companys");
            HasKey(c => c.CompanyID);
            Property(c => c.CompanyID).HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity);
            Property(c => c.Address).HasMaxLength(200);
            Property(c => c.Contact);
            Property(c => c.Culture);
            Property(c => c.Email).HasMaxLength(20);
            Property(c => c.Fax).HasMaxLength(30);
            Property(c => c.Introduction);
            Property(c => c.Name).HasMaxLength(200);
            Property(c => c.Phone).HasMaxLength(30);
            Property(c => c.PublishNumber).HasMaxLength(20);
            Property(c => c.ContactName).HasMaxLength(30);
            Property(c => c.Intro).HasMaxLength(250);

            Property(c => c.MediaUrl).HasMaxLength(250);

            HasMany(c => c.Albums).WithRequired(c => c.Company).HasForeignKey(c=>c.CompanyId);

            HasMany(c => c.Documents).WithRequired(c => c.Company).HasForeignKey(c => c.CompanyId);

            HasMany(c => c.Medias).WithRequired(c => c.Company).HasForeignKey(c=>c.CompanyId);
        }
    }
}
